<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function wanMeiShu(num) {
            var sum = 0
            for (var i = 1; i < num; i++) {
                if (num % i === 0) {
                    sum += i
                }
            }
            if (sum == num) {
                alert(num + "是完美数")
            } else {
                alert(num + "不是完美数")
            }
        }
        var num = parseInt(prompt("请输入一个整数"))
        wanMeiShu(num)
    </script>
</head>

<body>

</body>

</html>